package com.lry.netty01.server.in;

import com.lry.netty01.server.Server;
import com.lry.netty01.server.queue.Task;
import com.lry.netty01.server.entity.FixedFrame;
import com.lry.netty01.server.queue.TaskQueue;
import com.lry.netty01.server.entity.Packet;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

/**
 * 实际的报文处理器
 */
@Slf4j
public class PacketHandler extends ChannelInboundHandlerAdapter {


    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {

    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        FixedFrame fixedFrame = (FixedFrame) msg;
        //心跳包1，注册包2，报警包3
        Server.offerTaskQueue(new Task(new Packet(true,ctx.channel(),fixedFrame)));
    }


}
